Skip to content

fix: remove three dead ends when switching from the App Store build - #479

Merged
tieubao merged 2 commits into
developfrom
fix/migration-dead-ends
Nov 15, 2026
Merged

tieubao merged 2 commits into
developfrom
fix/migration-dead-ends

Conversation

@tieubao

@tieubao tieubao commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Why

The flow review of the App Store to direct switch found three dead ends left after #474 and #475. In each one the direct build stops and says nothing. This lands before 1.11.3 (#476 rebases on it).

What (direct build only, #if HIDDENBAR_NATIVE_VISIBILITY)

launch
  │
  ├─ another copy with our bundle id running?
  │     direct copy ───────────▶ bring it forward, quit (as before)
  │     App Store copy ────────▶ "Hidden Bar from the App Store is running.
  │                               Quit it and switch to this version?"
  │                                 Quit and Switch ─▶ terminate, wait 5 s, force, continue
  │                                 Cancel ──────────▶ bring it forward, quit (as before)
  ├─ 1. import offer (unchanged)
  ├─ 2. trash offer ─▶ waits for the Trash to finish
  └─ 3. move check, whatever the Trash answer was
        running from /Applications ───────────▶ nothing
        /Applications not writable ───────────▶ alert: ask an administrator to drag it in
        App Store copy kept in /Applications ─▶ alert: trash that copy, drag this one in
        else ─────────────────────────────────▶ move offer (unchanged)
  1. App Store copy running. OtherRunningCopy.decide replaces the silent quit in the direct build. An App Store copy is a bundle with _MASReceipt/receipt, or one with a Mac App Store signature (leaf OID 1.2.840.113635.100.6.1.9) when the receipt is missing. The bundle is taken from the process's executable path. With two bundles under one id, NSRunningApplication.bundleURL named the wrong copy in the harness. When a direct copy is also running, it still wins silently. The App Store build keeps the old guard.
  2. Trash "Not now" hid the move step. MoveToApplications.plan no longer goes silent when the App Store copy holds /Applications/Hidden Bar.app. The move check also runs after NSWorkspace.recycle completes, so a copy that was just trashed frees /Applications. Before, the check could run before the Trash finished.
  3. No usable /Applications. ~/Applications is not honoured by macOS 27 (on-screen check below), so it is not offered. When /Applications is not writable, or holds the App Store copy the user kept, a one-time alert gives the steps in plain words. For the same reason, NativeVisibilityEngine.isInApplicationsFolder (fix: a microphone in use no longer blocks hiding (1.11.2 regression) #475) now accepts /Applications only. A copy in ~/Applications fails open (hides nothing, keeps its arrow) and gets the move offer.

Debug builds get -debugAnswerAlerts switch=first,move=second (alert ids: switch, import, trash, move, explain, error). Each named alert takes its answer after 3 s. Any alert not named is aborted, which records nothing. Like -forceAppStoreMigration, it is Debug only.

Proof

Check Result
Unit tests 8 new tests in AppStoreMigrationTests (fake running-app list, fake paths, fake writability, a fake /Applications on disk), replacing testMoveOfferRules; all pass
Negative control: old rules behind the new signatures 6 fail: testRunningAppStoreCopyIsOfferedAQuit, testRunningDirectCopyStillWinsSilently, testDebugRulesOnlyCountTheSamePathUnlessForced, testKeptAppStoreCopyInApplicationsExplainsWhatToDo, testUnwritableApplicationsExplainsWhatToDo, testMovePlanReadsTheFolderAndTheKeptAppStoreCopy
scripts/test.sh Hidden Bar 236 passed, App Store 173 passed, 0 failed
Release warnings, clean builds, develop vs this branch Release-Direct 4 vs 4, App Store Release 2 vs 2, none new
On screen, ~/Applications (hooks: expand, collapse, install-location-check on) Debug-Direct copy in ~/Applications: arrow EMPTY after collapse, state=collapsed held=True, placed far left (x 723) like an unknown app. Same build from the scratchpad: EMPTY. Verdict: not honoured.
On screen, dead end 1 (hooks only; fake App Store copy = Debug build plus _MASReceipt/receipt) Quit and Switch: the App Store copy exited and the candidate kept running. Cancel: the candidate exited and the App Store copy kept running. A second launch of the same direct build quit silently (quitInFavorOf). Release-Direct develop: exits silently next to the App Store copy (the bug). Release-Direct on this branch: stays up on the alert (screenshot below).

Alert copy as captured: "Hidden Bar from the App Store is running. Quit it and switch to this version?" / "Only one Hidden Bar can run at a time. The App Store version stays installed until you choose otherwise." / [Quit and Switch] [Cancel].

Not in this PR

  • "Not now" on the move offer is still final, as in feat: import settings and tidy up when switching from the App Store build #474.
  • The ~/Applications result is from one machine (macOS 27.2) with an exec-launched Debug-Direct build. An install by open or at login was not tested from ~/Applications.
  • After Quit and Switch, the App Store copy's login item still starts it at the next login. The new prompt then appears again until the user trashes that copy; that is not a dead end.

The flow review of the App Store to direct switch found three places where
the direct build stops with no message:

- An App Store copy that is running (often a login item) made the direct
  build's single-instance guard quit silently, so none of the switch offers
  ran. The direct build now asks "Hidden Bar from the App Store is running.
  Quit it and switch to this version?". Quit and Switch terminates it (then
  forces it after 5 s) and launching continues; Cancel quits as before.
  Another direct copy still wins silently. A copy counts as the App Store
  build when its bundle has _MASReceipt/receipt or a Mac App Store signature.
- "Not now" to the Trash offer left the App Store copy in /Applications, and
  the move offer never showed. The move offer no longer depends on it; it
  also waits for the Trash to finish, so a trashed copy frees /Applications.
- When /Applications is not writable, or holds the App Store copy the user
  kept, the move goes to ~/Applications (created when missing). When neither
  folder can take it, an alert says plainly what to do.

The decisions are pure functions (OtherRunningCopy.decide,
MoveToApplications.plan) with unit tests that fail under the old rules.
Debug builds get a -debugAnswerAlerts hook so a harness can answer the
alerts without pointer or key input.
On macOS 27, a Debug-Direct build run from ~/Applications lost its arrow on
collapse, the same as a build run from a build folder. Tested with the hooks
harness, install-location check on: arrow EMPTY, held=True, placed far left
like an app the system does not know. So ~/Applications is not a fix:

- The move offer no longer targets ~/Applications. When /Applications is
  not writable, or holds the App Store copy the user kept, a one-time alert
  says what to do.
- NativeVisibilityEngine.isInApplicationsFolder checks /Applications only,
  so a copy in ~/Applications fails open instead of losing its arrow.
- The other-copy check reads the bundle from the executable path: with two
  bundles under one id, NSRunningApplication.bundleURL can name the other copy.
- -debugAnswerAlerts now names alerts (switch=first,...); every alert not
  named is aborted, so a harness answer can never move or trash an app.
@tieubao
tieubao merged commit 48ffcc4 into develop Nov 15, 2026
1 check passed
tieubao added a commit that referenced this pull request Nov 15, 2026
tieubao added a commit that referenced this pull request Nov 15, 2026
MARKETING_VERSION 1.12.0 and CURRENT_PROJECT_VERSION 19 in all 8 app
configurations (Direct x4, App Store x4).

CHANGELOG: the Unreleased section becomes v1.12.0 (2026-11-15) and folds in
the unshipped 1.11.3 entry (#475, #474, #479); there is no separate 1.11.3
section. The microphone checkbox is named as the redesigned Settings window
labels it.

RUNBOOK: step 5 uploads a byte-identical Hidden-Bar-macos.zip, so
releases/latest/download/Hidden-Bar-macos.zip stays stable (carried over
from #476).
tieubao added a commit that referenced this pull request Nov 15, 2026
MARKETING_VERSION 1.12.0 and CURRENT_PROJECT_VERSION 19 in all 8 app
configurations (Direct x4, App Store x4).

CHANGELOG: the Unreleased section becomes v1.12.0 (2026-11-15) and folds in
the unshipped 1.11.3 entry (#475, #474, #479); there is no separate 1.11.3
section. The microphone checkbox is named as the redesigned Settings window
labels it.

RUNBOOK: step 5 uploads a byte-identical Hidden-Bar-macos.zip, so
releases/latest/download/Hidden-Bar-macos.zip stays stable (carried over
from #476).
@tieubao
tieubao deleted the fix/migration-dead-ends branch November 15, 2026 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant